package vip.meeet.gc;

public class DeadLock {
    private static Object A = new Object();
    private static Object B = new Object();
    public static void main(String[] args) {
        testDeadLock();
    }
    
    public static void testDeadLock(){
        Thread aThread = new Thread(new Runnable() {
            
            @Override
            public void run() {
                synchronized(A){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    synchronized(B){
                        System.out.println("this is A thread");
                    }
                }
            }
        });
       Thread bThread = new Thread(new Runnable() {
            
            @Override
            public void run() {
                synchronized(B){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    synchronized(A){
                        System.out.println("this is B thread");
                    }
                }
            }
        });
       aThread.start();
       bThread.start();
    }
    
}
